﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using QTPlugin;

namespace Kawanon.QtHoney
{
	public partial class AboutForm : Form
	{
		public AboutForm()
		{
			InitializeComponent();
		}

		private void InitializeButtons()
		{
			MainPlugin main = new MainPlugin();
			main.Initialize(null);

			ImageList il = new ImageList();
			il.ColorDepth = ColorDepth.Depth32Bit;
			listView1.SmallImageList = il;

			for (int i = 0; i < main.Count; i++)
			{
				il.Images.Add(main.GetImage(false, i));

				listView1.Items.Add(new ListViewItem(main.GetName(i), il.Images.Count - 1));
			}
		}

		private string GetVersion()
		{
			object[] attrs = typeof(MainPlugin).GetCustomAttributes(typeof(PluginAttribute), true);
			if (attrs.Length != 1)
			{
				return null;
			}
			PluginAttribute attr = (PluginAttribute)attrs[0];
			return attr.Version;
		}

		private void AboutForm_Load(object sender, EventArgs e)
		{
			//toolStrip1.Items.Clear();

			textBoxVersion.Text = String.Format("QTHoney {0}", GetVersion());

			InitializeButtons();

			Array.ForEach(new LinkLabel[] { linkLabel1 }, delegate(LinkLabel linkLabel)
			{
				linkLabel.LinkClicked += delegate(object sender2, LinkLabelLinkClickedEventArgs e2)
				{
					linkLabel.LinkVisited = true;
					Process.Start(linkLabel.Text);
				};
			});
		}
	}
}
